/**
 * 
 */
package org.dragonfire.dasm.instr.rules;

import org.dragonfire.dasm.instr.Rule;
import org.dragonfire.dasm.postprocessor.Postprocessor;

/**
 * @author Darth Android
 * @date Jul 17, 2007
 */
public class SWAPRule extends Rule {

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.dragonfire.dasm.instr.Rule#evalParam(java.lang.String)
	 */
	@Override
	public String evalParam(Postprocessor post, String bits) {
		if (bits.length() % 8 != 0)
			throw new IllegalArgumentException("The number of bits must be a multiple of 8.");
		String newBits = "";
		for (int i = bits.length() / 8 - 1; i >= 0; i--) {
			newBits += bits.substring(i * 8, (i + 1) * 8);
		}
		return newBits;
	}
}
